extends "../huayuan-1/huayuan-1.gd"


func _extInit():
	._extInit()
	lv = 2             #等级的设置
	addSkill("战斗开始时，将位于自己同行对称位置的敌人引到附近并强制决斗，若该目标死亡，永久提高2点炮击<限定>并再次发动挑战宣言", "挑战宣言")
	
var tzCha = null
func _onBattleEnd():
	._onBattleEnd()
	tzCha = null
	sk2Flag = true

var sk2Flag = true
func _onBattleStart():
	._onBattleStart()
	tzxy()

#挑战宣言
func tzxy():
	#判定对称位置
	var cha = sys.main.matCha(Vector2(9 - cell.x, cell.y))
	if cha == null or cha.team == team:
		#判定血上限最低
		cha = getFirstCha(1, "sortByMaxHp")

	if cha == null:return
	#判定附近位置
	for i in config.aroundCells:
		if matCha(cell+i) == null and cha.setCell(cell+i):
			tzCha = cha
			tzCha.addBuff(buff.b_xuanYun.new(3))
			aiCha = tzCha
			return

func _upS():
	._upS()
	if tzCha != null:
		if tzCha.isDeath:
			tzCha == null
			jdSuccess()
		else:
			tzCha.aiCha = self

func jdSuccess():
	#决斗胜利
	if sk2Flag:
		sk2Flag = false
		attEx.atk += 2
		if upgraded == 2:
			attEx.criR += 0.01
	upAtt()
	tzxy()

	